package com.nbjtjc.safe.api.sys;

import com.nbjtjc.common.validator.ValidatorUtils;
import com.nbjtjc.common.validator.group.DeleteGroup;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.mapper.sys.SysUserPostMapper;
import com.nbjtjc.safe.model.sys.SysPost;
import com.nbjtjc.safe.model.sys.SysUserPost;
import com.nbjtjc.safe.service.sys.SysUserPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther guqianbin
 * @date 2018/8/8 16:09
 * 用户岗位
 **/
@RestController
@RequestMapping("/userPost")
@CrossOrigin("*")
public class SysUserPostController {

    @Autowired
    private SysUserPostService sysUserPostService;


    @PostMapping("/add")
    public Result<SysPost> add(SysUserPost sysUserPost){
        ValidatorUtils.validateEntity(sysUserPost);
        Result result=new Result<>();
        result=sysUserPostService.add(sysUserPost);
        return result;
    }

    @PostMapping("/delete")
    public Result<SysPost> delete(SysUserPost sysUserPost){
        ValidatorUtils.validateEntity(sysUserPost, DeleteGroup.class);
        Result result=new Result<>();
        result=sysUserPostService.delete(sysUserPost);
        return result;
    }

}
